package com.junxonline.instant.admin.controller.logDevice;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.junxonline.instant.dao.entity.vo.logDevice.LogDeviceOperationVO;
import com.junxonline.instant.admin.service.config.OrganizationService;
import com.junxonline.instant.admin.service.logDevice.LogDeviceOperationService;
import com.junxonline.instant.common.annotation.OperationLog;
import com.junxonline.instant.common.entity.common.CommonReqPage;
import com.junxonline.instant.common.entity.common.CommonResult;
import com.junxonline.instant.common.enumeration.OperationEnum;
import lombok.extern.log4j.Log4j2;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 终端操作日志Controller
 *
 * @author JunX
 * @date 2021-11-03
 */
@Log4j2
@RestController
@RequestMapping(value = "/logDevice/logDeviceOperation")
public class LogDeviceOperationController {

    @Autowired
    private LogDeviceOperationService logDeviceOperationService;

    @Autowired
    private OrganizationService organizationService;

    /**
     * 查询组织机构树（TreeSelect）
     *
     * @return CommonResult
     */
    @RequiresPermissions(value = "logDevice:logDeviceOperation:query")
    @OperationLog(label = "终端操作日志-查询组织机构树", type = OperationEnum.QUERY)
    @PostMapping(value = "/queryOrganizationTree")
    public CommonResult queryOrganizationTree() {
        return CommonResult.success(organizationService.queryOrganizationTree(new QueryWrapper<>()));
    }

    /**
     * 查询终端连接日志列表
     *
     * @param vo 请求参数
     * @return CommonResult
     */
    @RequiresPermissions(value = "logDevice:logDeviceOperation:query")
    @OperationLog(label = "终端操作日志-查询列表", type = OperationEnum.QUERY)
    @PostMapping(value = "/queryList")
    public CommonResult queryList(@RequestBody(required = false) CommonReqPage<LogDeviceOperationVO> vo) {
        return CommonResult.success(logDeviceOperationService.queryList(vo, new QueryWrapper<>()));
    }

    /**
     * 导出
     *
     * @return CommonResult
     */
    @RequiresPermissions(value = "logDevice:logDeviceOperation:export")
    @OperationLog(label = "终端操作日志-导出", type = OperationEnum.EXPORT)
    @PostMapping(value = "/exportExcel")
    public CommonResult exportExcel() {
        return CommonResult.success();
    }
}
